package com.heima.article.listener;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.mq.NewsUpOrDownConstants;
import com.heima.common.constants.wemedia.WemediaConstants;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ArticleUpOrDownListener {
    @Resource
    ApArticleService service;

    @RabbitListener(queuesToDeclare = @Queue(name = NewsUpOrDownConstants.NEWS_DOWN_FOR_ARTICLE_CONFIG_QUEUE))
    public void articleDown(@Payload String articleId){
        service.DownOrUpArticle(Long.parseLong(articleId), WemediaConstants.WM_NEWS_DOWN);
    }
    @RabbitListener(queuesToDeclare = @Queue(name = NewsUpOrDownConstants.NEWS_UP_FOR_ARTICLE_CONFIG_QUEUE))
    public void articleUp(@Payload String articleId){
        service.DownOrUpArticle(Long.parseLong(articleId), WemediaConstants.WM_NEWS_UP);
    }
}
